<?php

class Core_Backend_Component_Customer_View_Showroom_Certificate_Generate extends Core_Backend_Share_View_Form {

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('index'), $this->__('share.button.back'));
        $group = $toolbar->createGroup('save');
        $group->addButton($this->__('share.button.save'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(NULL, 'certificate-generate') . "')");
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $form->setAction($this->getUrl())
                ->setId('model_form')
                ->addHiddenField('id', 'model[id]')
                ->addHiddenField('showroom_id', 'model[showroom_id]', $this->getShowroom()->getId());
        $form->addTextboxField($this->__('customer.label.quantity'), 'quantity', 'quantity', TRUE)
                ->addRequiredRule()
                ->addDigitsRule()
                ->setValue(1);
        $form->addTextboxField($this->__('customer.label.access_times'), 'access_times', 'model[access_times]')
                ->addDigitsRule();
        $form->addDatetimeField($this->__('customer.label.expiry_date'), 'expiry_date', 'model[expiry_date]');
        parent::buildForm($form);
    }

}